package com.atguigu.springmvc.demo01.controller;

import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

/**
 * @author yanglin
 * @create 2023-12-25 9:01 星期一
 * description:
 */
@ControllerAdvice
public class ExceptionController {
    
    
    @ExceptionHandler(value = {ArithmeticException.class,NullPointerException.class})
    public String testException(Exception exception, Model model){
        model.addAttribute("ex",exception);
        return "error";
    }
    
}
